From: tsteven4 Date: Sat, 9 Mar 2019 16:44:04 +0000 (-0700) Subject: clean up gui main and fix a png. (#313) X-Git-Tag: archive/raspbian/1.10.0+ds-2+rpi1~1^2~12^2~8^2~29 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22Program/%22http:/www.example.com/cgi/%22https:/%22Program?a=commitdiff_plain;h=6cf0660e74de8ae1462e5aa355be864553f01109;p=gpsbabel.git clean up gui main and fix a png. (#313) * clean up gui main and fix a png. - fix libpng warning: iCCP: known incorrect sRGB profile issue with runit.png with pngcrush. - fix includes for gui/main.cc, including removal of CoreFoundation.h - use QApplication static methods instead of going directly to the underlying QCoreApplication static methods. - no path setting in GUI, instead pass the full path to gpsbabel when using QProcess::start. in formatload.cc xlt() use qt methods to get a char* instead of resorting to stdlib. At this point Qt assumes all translate strings are utf8. However, the formatload xlt intent doesn't work because 1) MainWindow::LoadLanguage hasn't been called when MainWindow::loadFormats is called. 2) the translations don't exist for the format bits from gpsbabel that fromatload tries to translate. I think this was the intent of the gpsbabel_*.ts files which are very out of date and no longer distributed. --- diff --git a/gui/formatload.cc b/gui/formatload.cc index fc806cf60..c8e1ed501 100644 --- a/gui/formatload.cc +++ b/gui/formatload.cc @@ -21,18 +21,27 @@ // //------------------------------------------------------------------------ -#include -#include -#include -#include -#include +#include // for QByteArray +#include // for operator==, QChar +#include // for QCharRef +#include // for QCoreApplication +#include // for QObject +#include // for QProcess +#include // for QRegExp +#include // for QString, operator+ +#include // for QTextStream +#include // for QVariant +#include // for QApplication +#include // for QMessageBox + #include "formatload.h" -#include "appname.h" +#include "appname.h" // for appName + //------------------------------------------------------------------------ static QString xlt(const QString& f) { - return QCoreApplication::translate("", f.toStdString().c_str()); + return QCoreApplication::translate("", f.toUtf8().constData()); } //------------------------------------------------------------------------ @@ -127,7 +136,7 @@ bool FormatLoad::getFormats(QList& formatList) formatList.clear(); QProcess babel; - babel.start("gpsbabel", QStringList() << "-^3"); + babel.start(QApplication::applicationDirPath() + "/gpsbabel", QStringList() << "-^3"); if (!babel.waitForStarted()) { return false; } diff --git a/gui/formatload.h b/gui/formatload.h index 2389d2444..370c1b598 100644 --- a/gui/formatload.h +++ b/gui/formatload.h @@ -25,7 +25,10 @@ #ifndef FORMATLOAD_H #define FORMATLOAD_H -#include "format.h" +#include // for QList +#include // for QStringList + +#include "format.h" // for Format class FormatLoad { diff --git a/gui/images/runit.png b/gui/images/runit.png index de9b58068..1ab7a1db7 100644 Binary files a/gui/images/runit.png and b/gui/images/runit.png differ diff --git a/gui/main.cc b/gui/main.cc index d92cc7bb5..a5672a4fc 100644 --- a/gui/main.cc +++ b/gui/main.cc @@ -20,26 +20,11 @@ // USA // //------------------------------------------------------------------------ -#define _CRT_SECURE_NO_DEPRECATE 1 -#include -#include -#include -#include -#include -#include +#include // for QT_VERSION, QT_VERSION_CHECK +#include // for QIcon +#include // for QApplication -#include "mainwindow.h" -#include "gmapdlg.h" - -#ifdef _WIN32 -const char* pathSeparator = ";"; -#else -const char* pathSeparator = ":"; -#endif - -#if defined (Q_OS_MAC) -#include -#endif +#include "mainwindow.h" // for MainWindow //------------------------------------------------------------------------ int main(int argc, char** argv) @@ -51,16 +36,9 @@ int main(int argc, char** argv) QApplication app(argc, argv); QApplication::setWindowIcon(QIcon(":/images/appicon.png")); - - QString newPath = "PATH=" + QApplication::applicationDirPath() + - QString(pathSeparator) + getenv("PATH"); - char* newPathEnv = new char[newPath.length() + 1]; - strcpy(newPathEnv, newPath.toStdString().c_str()); - putenv(newPathEnv); - - QCoreApplication::setOrganizationName("GPSBabel"); - QCoreApplication::setOrganizationDomain("gpsbabel.org"); - QCoreApplication::setApplicationName("GPSBabel"); + QApplication::setOrganizationName("GPSBabel"); + QApplication::setOrganizationDomain("gpsbabel.org"); + QApplication::setApplicationName("GPSBabel"); MainWindow mainWindow(nullptr); mainWindow.show(); diff --git a/gui/mainwindow.cc b/gui/mainwindow.cc index 781c946dc..157e0db9e 100644 --- a/gui/mainwindow.cc +++ b/gui/mainwindow.cc @@ -19,32 +19,58 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 // USA // -#include -#include -#include -#include -#include -#include -#include -#include -// #include +#include // for QByteArray +#include // for QDate +#include // for QDateTime +#include // for QDir +#include // for QEvent (& QEvent::LanguageChange, QEvent::LocaleChange) +#include // for QFile +#include // for QFileInfo +#include // for QLocale +#include // for QMimeData +#include // for QProcess, QProcess::NotRunning +#include // for QRegExp +#include // for QSettings +#include // for QTemporaryFile +#include // for QTime +#include // for QUrl +#include // for QVariant +#include // for SmoothTransformation, WaitCursor +#include // for foreach +#include // for QCursor +#include // for QDesktopServices +#include // for QIcon +#include // for QImage +#include // for QApplication, qApp +#include // for QCheckBox +#include // for QDialogButtonBox +#include // for QFileDialog +#include // for QMessageBox, operator|, QMessageBox::Yes, QMessageBox::No +#include // for QPlainTextEdit +#include // for QPushButton +#include // for QRadioButton +#include // for QStackedWidget + +#include // for exit #include "mainwindow.h" -#include "../gbversion.h" -#include "aboutdlg.h" -#include "advdlg.h" -#include "appname.h" -#include "babeldata.h" -#include "donate.h" -#include "filterdlg.h" -#include "formatload.h" -#include "gmapdlg.h" -#include "help.h" -#include "optionsdlg.h" -#include "preferences.h" -#include "processwait.h" -#include "version_mismatch.h" -#include "upgrade.h" +#include "../gbversion.h" // for VERSION +#include "aboutdlg.h" // for AboutDlg +#include "advdlg.h" // for AdvDlg +#include "appname.h" // for appName +#include "babeldata.h" // for BabelData +#include "donate.h" // for Donate +#include "filterdlg.h" // for FilterDialog +#include "formatload.h" // for FormatLoad +#include "gmapdlg.h" // for GMapDialog +#include "help.h" // for ShowHelp +#include "optionsdlg.h" // for OptionsDlg +#include "preferences.h" // for Preferences +#include "processwait.h" // for ProcessWaitDialog +#include "upgrade.h" // for UpgradeCheck +#include "version_mismatch.h" // for VersionMismatch + + const int BabelData::noType_ = -1; const int BabelData::fileType_ = 0; @@ -56,7 +82,7 @@ const int BabelData::deviceType_ = 1; QString MainWindow::findBabelVersion() { QProcess babel; - babel.start("gpsbabel", QStringList() << "-V"); + babel.start(QApplication::applicationDirPath() + "/gpsbabel", QStringList() << "-V"); if (!babel.waitForStarted()) { return QString(); } @@ -869,7 +895,7 @@ bool MainWindow::runGpsbabel(const QStringList& args, QString& errorString, { QProcess* proc = new QProcess(nullptr); QString name = "gpsbabel"; - proc->start(name, args); + proc->start(QApplication::applicationDirPath() + '/' + name, args); ProcessWaitDialog* waitDlg = new ProcessWaitDialog(nullptr, proc); if (proc->state() == QProcess::NotRunning) { diff --git a/gui/mainwindow.h b/gui/mainwindow.h index 31d539927..94920935c 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -22,13 +22,29 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H -#include "ui_mainwinui.h" -#include "format.h" -#include "filterdata.h" -#include "babeldata.h" -#include "upgrade.h" +#include // for QEvent +#include // for QList +#include // for QObject (& Q_OBJECT, slots) +#include // for QString +#include // for QStringList +#include // for QTranslator +#include // for QCloseEvent +#include // for QDragEnterEvent +#include // for QDropEvent +#include // for QPixmap +#include // for QAction +#include // for QComboBox +#include // for QLabel +#include // for QLineEdit +#include // for QMainWindow +#include // for QWidget + +#include "babeldata.h" // for BabelData +#include "filterdata.h" // for AllFiltersData +#include "format.h" // for Format +#include "ui_mainwinui.h" // for Ui_MainWindow +#include "upgrade.h" // for UpgradeCheck -#include class MainWindow: public QMainWindow {